/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			mw_basicmdi.h
  \date			Sep 2011
  \author		TNick

  \brief		Contains the definition for basic MDI in MainWindow


  Copyright (c) 2011, Nicu Tofan
 All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
	* Redistributions of source code must retain the above copyright
	  notice, this list of conditions and the following disclaimer.
	* Redistributions in binary form must reproduce the above copyright
	  notice, this list of conditions and the following disclaimer in the
	  documentation and/or other materials provided with the distribution.
	* Neither the name of the copyright holder nor the
	  names of its contributors may be used to endorse or promote products
	  derived from this software without specific prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 DISCLAIMED. IN NO EVENT SHALL NICU TOFAN BE LIABLE FOR ANY
 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __MAINWINDOW_BASICMDI_INC__
#define __MAINWINDOW_BASICMDI_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

class	MdiChild;

namespace Ui {
class MainWindow;
}

#include	<main.h>

#include	<QObject>
#include	<QMdiSubWindow>
#include	<QAction>


/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

/// logic unit responsible for providing common functionality for using Multiple Document Interface in MainWindow.
/**
*	The instance will connect itself during the MW_BasicMdi::initBasicMdi
*	to menus ussualy located in \b Window menu, allowing standard
*	arrangements (tile, cascade), navigation (previous, next) and
*	document close (one or all).
*
*	Active MDI document is also tracked and made available to MainWindow,
*	thus allowing certain GUI elements to be enabled only when a document is
*	present. Active document is also evidentiated in the list of opened
*	documents, also hosted usually in \b Window menu.
*
*	MW_BasicMdi::findMdiChild() may be used to find the document that
*	has a particular title.
*/
class	MW_BasicMdi : public QObject		{
	Q_OBJECT

	friend class MainWindow;

	friend class MW_BasicSlots;
	friend class MW_RecentFiles;
	friend class MW_SheetSlots;
	friend class MW_StyleSheets;
	friend class MW_UiTempl;

	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */
public:

	MW_BasicMdi		() ;
	~MW_BasicMdi	() ;


protected:

	/// connects the actions with designed slots
	void				initBasicMdi		(Ui::MainWindow * lc_ui);

	/// create a new document in MDI
	MdiChild *          createMdiChild      ( void );

	/// tell which is the active document in MDI
	MdiChild *          activeMdiChild      ( void );

	/// finds associated document for a given file
	QMdiSubWindow *     findMdiChild        (const QString &fileName);



protected slots:

	/// informed when active document has changed
	void    slot_ActiveMdiChange    (QMdiSubWindow* p_active);

	/// informed when active document has changed
	void    slot_ActiveMdiChange    (MdiChild* p_active);

	/// used by the windows menu to change active document
	void    slot_DoChangeMdi		(QAction* p_active);

	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

}; /* class MW_BasicMdi*/

/*  CLASS    =============================================================== */
//
//
//
//
#endif // __MAINWINDOW_BASICMDI_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
